//
//  MapFlipsideVC.m
//  HelloWordPrimer
//
//  Created by Anton Johansson on 10/16/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "MapFlipsideVC.h"


@implementation MapFlipsideVC
@synthesize delegate;
@synthesize mapView;
@synthesize mapTypeControll;


- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
	NSLog(@"Yle");
}

- (IBAction)done {
	[self.delegate flipsideViewControllerDidFinish:self];	
}


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
	mapTypeControll.autoresizingMask = ( UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
	mapTypeControll.center;
	//self.view.autoresizingMask = ( UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
	NSLog(@"Viewdidload");
	//mapView.mapType = MKMapTypeStandard;
	switch (mapView.mapType) {
		case MKMapTypeStandard:
			NSLog(@"Found standard");
			mapTypeControll.selectedSegmentIndex = 0;
			break;
		case MKMapTypeHybrid:
			NSLog(@"Found hybrid");
			mapTypeControll.selectedSegmentIndex = 1;
			break;
		case MKMapTypeSatellite:
			NSLog(@"Found satellite");
			mapTypeControll.selectedSegmentIndex = 2;
			break;
		default:
			NSLog(@"View load found no type of map");
			break;
	}
}

#pragma mark -
#pragma mark MapType
- (IBAction)mapTypeChange:(id)sender {
	int selectedType = [sender selectedSegmentIndex];
	NSLog([NSString stringWithFormat:@"Selected type: %d", selectedType]);
	switch (selectedType) {
		case 0:
			mapView.mapType = MKMapTypeStandard;
			break;
		case 1:
			mapView.mapType = MKMapTypeHybrid;
			break;
		case 2:
			mapView.mapType = MKMapTypeSatellite;
			break;
		default:
			break;
	}
}


- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	mapView = nil;
	mapTypeControll = nil;
}

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
	return TRUE;
}


- (void)dealloc {
	NSLog(@"Deadalloc flipside");
    [super dealloc];
	[mapView release];
	[mapTypeControll release];
}


@end
